<?php
class TController
{
	protected $v;
	protected $s;

	protected $models = array();
	protected $m = array();

	public function __construct(){
		foreach($this->models as $model){
			$res = $this->createModel($model);
			$this->m[$model] = $res;
		}
	}

	protected function _createModel($m){
		if(!class_exists($m)){
			throw new Exception('Load Model error', 10);
		}
		$i = new $m($this);
		if($i instanceof TModel){
			throw new Exception('No TModel error',11);
		}
		return $i;
	}

	public function set($obj){
		if($obj instanceof TValidate) $this->v = $obj;
		if($obj instanceof TSanitize) $this->s = $obj;
		return $this;
	}

	public function exe($a){
		if(!function_exists($this, $a)){
			throw new EView();
		}
		$this->$a();
	}
}
